package org.JQbitorrentClinet.base;

import lombok.extern.slf4j.Slf4j;
import org.JQbitorrentClinet.QBitorrentConnectionInfo;
import org.JQbitorrentClinet.utils.RequestHandler;

@Slf4j
public abstract class BaseApiProcesser {
    protected QBitorrentConnectionInfo connectionInfo;

    public BaseApiProcesser(QBitorrentConnectionInfo connectionInfo) {
        this.connectionInfo = connectionInfo;
    }

    protected static Object process(BaseParam baseParam, QBitorrentConnectionInfo connectionInfo) {
        log.info("BaseProcess:" + baseParam.getApiUrl());
        Object response = RequestHandler.handleRequest(baseParam, connectionInfo);
        log.info("BaseProcess:" + baseParam.getApiUrl() + ";Response:" + response);
        return response;
    }

    protected <T> T process(BaseParam baseParam) {
        return (T) process(baseParam, connectionInfo);
    }
}
